package com.spica.platform.base.encrypt.encryptbody.exception;

import com.spica.platform.base.exception.errorcode.IErrorCode;
import com.spica.platform.common.utils.StringUtil;

import java.util.Arrays;

public enum IllegalSecurityTypeRtnCodEnum implements IErrorCode {
    UN_KNOWN_ILLEGAL_SECURITY_ERROR("BASE_ILLEGAL_SECURITY_00000", "未知安全异常"),
    ENHANCE_ILLEGAL_SECURITY_ERROR("BASE_ILLEGAL_SECURITY_00001", "illegal security type. (非法的安全类型)"),
    ;
    private String rtnCod;
    private String rtnMsg;

    IllegalSecurityTypeRtnCodEnum(String rtnCod, String rtnMsg) {
        this.rtnCod = rtnCod;
        this.rtnMsg = rtnMsg;
    };
    @Override
    public String getRtnMessage() {
        return rtnMsg;
    }

    @Override
    public String getRtnCode() {
        return rtnCod;
    }

    @Override
    public IErrorCode getInstanceByErrorCode(String rtnCod) {
        return Arrays.stream(IllegalSecurityTypeRtnCodEnum.values())
                .filter(illegalSecurityTypeRtnCodEnum -> StringUtil.equals(illegalSecurityTypeRtnCodEnum.rtnCod, rtnCod))
                .findFirst().orElse(IllegalSecurityTypeRtnCodEnum.UN_KNOWN_ILLEGAL_SECURITY_ERROR);
    }
}
